#!/usr/bin/env bash

echo "Ok,let's go!"

readonly RootDir=$(eval pwd)

if [ -z "$(which cipd)" ]; then
  cd connectedhomeip && source ./scripts/activate.sh && cd ${RootDir}
fi

if [ -z "$(which aarch64-none-linux-gnu-gcc)" ]; then
  export PATH=$PATH:/home/zengyun/workspace/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu/bin
fi

if [[ "$1" = "linux" ]]; then
  gn gen out/linux --args='target_os="linux" target_cpu="arm64"'
  ninja -C out/linux --verbose
  aarch64-linux-gnu-strip out/linux/chip-bridge-app
else
  gn gen out/host
  ninja -C out/host --verbose
fi

